package com.test.plugin;

import android.app.Activity;
import android.os.SystemClock;

import java.util.HashMap;
import java.util.Map;

public class StaticUtils {

    private static Map<String, Long> startRecord = new HashMap<>();

    public static void onActivityCreateStart(Activity activity) {
        String name = activity.getClass().getCanonicalName();
        long mills = SystemClock.uptimeMillis();
        System.out.println("StaticUtils: " + name + "  onCreate start at " + mills);
        startRecord.put(name, mills);
    }

    public static void onActivityCreateEnd(Activity activity) {
        String name = activity.getClass().getCanonicalName();
        long current = SystemClock.uptimeMillis();
        long cost = -1;
        if (startRecord.get(name) != null) {
            cost = current - startRecord.get(name);
        }
        System.out.println("StaticUtils: " + name + "  onCreate end at " + current + ", cost time:" + cost);
        startRecord.remove(name);
    }
}
